package com.esun.cheetah.biz.personal.personalcommunicater;

import java.util.HashMap;

import org.json.JSONException;
import org.json.JSONObject;

import android.os.Handler;

import com.esun.cheetah.biz.personal.personalinfo.RechargeUserInfo;
import com.esun.cheetah.biz.personal.personalinfo.UserInfo;
import com.esun.cheetah.config.BizCode;
import com.esun.cheetah.config.Key;
import com.esun.cheetah.network.AbsInferiorityCommunicater;
import com.esun.util.log.EDebug;
/**
 * 
 * @Package com.esun.cheetah.biz.personal.personalcommunicater.WithdrawalCommunicater
 * @ClassName: WithdrawalCommunicater
 * @Description: TODO(WithdrawalCommunicater)
 * @author handy <br/>
 * @date create at 2012-7-31 下午3:12:07
 *
 */
public class WithdrawalCommunicater extends AbsInferiorityCommunicater {
	private String status;// 状态
	private String msg;// 返回信息
	private String isbind;
	private String truename;
	private String money;
	private String mobile;
	private String cardnumber;
	private String bankname;

	public WithdrawalCommunicater(Handler handler, String truename,
			String money, String mobile) {
		super(handler);
		this.truename = truename;
		this.money = money;
		this.mobile = mobile;

	}

	@Override
	public HashMap<String, String> comHashMap() {
		HashMap<String, String> hmJson = new HashMap<String, String>();
		hmJson.put(Key.KEY_ID, BizCode.BIZCODE_WITHDRAWAL);
		hmJson.put(Key.CK, UserInfo.getUserInfo().getCk());
		hmJson.put("money", money);
		hmJson.put("truename", truename);
		hmJson.put("mobile", mobile);
		// hmJson.put(Key.CK,
		// "MTE2NTgyOTU1MTA1YTdmOThmMDEwMDBlYjI3N2Q4ZTA2NmQyYTRmYQ==");

		return hmJson;
	}

	@Override
	public void getJsonContent(String serverRes) throws JSONException {

		JSONObject json = new JSONObject(serverRes);
		status = json.getString(Key.STATUS);
		msg = json.getString(Key.MSG);

		EDebug.o("msg---" + msg);
		EDebug.o("status---" + status);
		if (Key.TRUE.equals(status)) {
			JSONObject jsondata = new JSONObject(json.getString(Key.DATA));
			isbind = jsondata.getString("isbind");
			bankname = jsondata.getString("bankname");
			EDebug.o("isbind---" + isbind);
			EDebug.o("bankname---" + bankname);
			cardnumber = jsondata.getString("carnumber");
			EDebug.o("cardnumber---" + cardnumber);
		}
		saveRechargeUserInfo();

	}

	private void saveRechargeUserInfo() {
		RechargeUserInfo.getUserInfo().setCardNum(cardnumber);
		RechargeUserInfo.getUserInfo().setBanckName(bankname);
	}

	public String getStatus() {
		return this.status;
	}

	public String getMsg() {
		return this.msg;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public String getCardnumber() {
		return this.cardnumber;
	}

	public void setCardnumber(String cardnumber) {
		this.cardnumber = cardnumber;
	}

	public String getIsbind() {
		return this.isbind;
	}

	public void setIsbind(String isbind) {
		this.isbind = isbind;
	}

	public String getTruename() {
		return this.truename;
	}

	public String getMoney() {
		return this.money;
	}

	public String getMobile() {
		return this.mobile;
	}

	public String getBankname() {
		return this.bankname;
	}

	public void setTruename(String truename) {
		this.truename = truename;
	}

	public void setMoney(String money) {
		this.money = money;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	public void setBankname(String bankname) {
		this.bankname = bankname;
	}

}